<style>
    root {
        /*min-height: 90vh;*/
        background-color: #f9fafb;
        width: 100%;
    }

    .sidebar {
        /*position: fixed;*/
        /*left: 0;*/
        /*top: 0;*/
        /*height: 100%;*/
        /*width: 256px;*/
        /*background-color: #2a8edd;*/
        border-right: 1px solid #e5e7eb;
    }

    .sidebar-header {
        display: flex;
        align-items: center;
        /*padding: 0 24px;*/
        height: 64px;
        border-bottom: 1px solid #e5e7eb;
    }

    .logo {
        width: 32px;
        height: 32px;
    }

    .logo-text {
        margin-left: 8px;
        font-weight: 500;
        color: var(--el-color-primary);
    }

    .main-content {
        /*margin-left: 256px;*/
        /*padding-bottom: 24px;*/
        width: 100%;
        margin-left: 5px;
    }

    .top-nav {
        height: 55px;
        /*background-color: white;*/
        border-bottom: 1px solid #e5e7eb;
        padding: 0 24px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 10px;
    }

    .nav-left {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .nav-right {
        display: flex;
        align-items: center;
        gap: 16px;
    }

    .user-info {
        display: flex;
        align-items: center;
        gap: 8px;
        cursor: pointer;
        /*opacity: 0.1;*/
    }
</style>
<div id="app" v-cloak class="root" style="height: calc(100vh - 30px)">
    <div class="flex-row flex-content-between">
        <!-- 左侧菜单 -->
        <el-menu :default-active="activeMenu" class="sidebar" mode="vertical" :collapse-transition="true"
                 popper-effect="light" :collapse="collapse">
            <div class="sidebar-header">
                <!--                    https://ai-public.mastergo.com/ai/img_res/59d84f7b885fa00c98c8a65edc99140f.jpg-->
                <img :src="Config.base.logo?Config.base.logo:`/app/muadmin/image/qrcode.png`"
                     class="logo" alt="logo">
                <span class="logo-text" v-if="!collapse">{{Config.base.name||`快速开发框架`}}</span>
            </div>
            <el-scrollbar style="height: calc(100vh - 100px)">
                <template v-for="item in menuItems" :key="item.id">
                    <menu-item :item="item" @add-main="addMain" @delmain="delMain" :contract="collapse"></menu-item>
                </template>
            </el-scrollbar>

        </el-menu>
        <!-- 主体内容 -->
        <div class="main-content">
            <!-- 顶部导航 -->
            <div class="top-nav" :style="{backgroundColor:theme.horizontal_background}">
                <div class="nav-left">
                    <el-icon title="收缩" class="shou" size="20" @click="collapse = !collapse">
                        <component :is="`Operation`"></component>
                    </el-icon>
                    <!--                    <el-icon title="菜单展现" class="shou" size="20" @click="collapse = !collapse"><component :is="`Menu`"></component></el-icon>-->
                    <!--                    <span>仪表盘</span>-->
                </div>
                <div class="nav-right flex-row flex-item-center">
                    <el-icon size="20" class="shou">
                        <Bell/>
                    </el-icon>
                    <el-icon size="20" class="cursor-pointer shou" @click="theme.showChangeTheme = true">
                        <Setting/>
                    </el-icon>
                    <el-dropdown>
                        <div class="user-info" :title="userInfo.nickname?userInfo.nickname:`管理员`">
                            <el-avatar :size="40"
                                       :src="userInfo.avatar?userInfo.avatar:`/app/muadmin/image/avatar.png`"/>
                            <span>{{userInfo.nickname||`管理员`}}</span>
                        </div>
                        <template #dropdown>
                            <el-dropdown-menu>
                                <el-dropdown-item @click="addUserInfo">个人信息</el-dropdown-item>
                                <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
                            </el-dropdown-menu>
                        </template>
                    </el-dropdown>
                </div>
            </div>
            <!-- 标签页 -->
            <el-tabs v-model="tabs.activeTab" type="card" @tab-remove="closeTab" @tab-change="changeTabs">
                <el-tab-pane v-for="tab in tabs.list"
                             :key="tab.key"
                             :label="tab.label"
                             :name="tab.key"
                             :closable="tab.key==1?false:true"
                >
                    <template #label>
                        <div class="flex items-center gap-2" @contextmenu.prevent="openMenu($event,tab.label)">
                            <el-icon v-if="tab.icon" :size="16">
                                <component :is="tab.icon"></component>
                            </el-icon>
                            {{ tab.label }}
                        </div>
                    </template>
                    <el-scrollbar style="height: calc(100vh - 138px);width:100%;">
                        <!--                                                <div>{{tab.route}}:{{tab.key}}</div>-->
                        <iframe :id="`myid_`+tab.key" :src="tab.route" frameborder="0"
                                style="width: 100%;min-height:83vh;overflow: hidden;background-color: #eeeeee"></iframe>
                    </el-scrollbar>
                </el-tab-pane>
            </el-tabs>
        </div>
    </div>
    <el-drawer
            v-model="drawer"
            title="I am the title"
            :direction="direction"
            :before-close="handleClose"
    >
        <span>Hi, there!</span>
    </el-drawer>
    <el-drawer v-model="theme.showChangeTheme" title="修改主题">
        <el-form :model="theme" label-width="auto" style="max-width: 600px">
            <el-form-item label="主题颜色">
                <el-color-picker v-model="theme.theme_color"/>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">保存到数据库</el-button>
                <el-button @click="onSubmitTemp">临时修改</el-button>
            </el-form-item>
        </el-form>
    </el-drawer>
</div>